# -*- coding: utf-8 -*-



## ------------------------------------------------------------
## Copyright 2010 Pierre-Antoine Delsart
## 
## This file is part of LeVin.
## 
## LeVin is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
## 
## LeVin is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with LeVin.  If not, see <http://www.gnu.org/licenses/>.
## ---------------------------------------------------------------


# Form implementation generated from reading ui file 'displayRate.ui'
#
# Created: Mon Nov 22 18:15:11 2010
#      by: PythonQt UI code generator 4.7.3
#
# WARNING! All changes made in this file will be lost!

from PythonQt import QtCore, QtGui
from qtcommon import tr

from tastingText import OrderedTastingAtt

def appendText(self, text):
    
    self.setText(t.comment if t.comment else "rien")

class Ui_Form(object):

    def setupUi(self, Form):
        self.wid = Form
        Form.setObjectName("Form")
        Form.resize(477, 160)
        self.verticalLayout = QtGui.QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label_year = QtGui.QLabel(Form)
        self.label_year.setObjectName("label_year")
        self.horizontalLayout.addWidget(self.label_year)
        self.label_rate = QtGui.QLabel(Form)
        self.label_rate.setObjectName("label_rate")
        self.horizontalLayout.addWidget(self.label_rate)
        self.verticalLayout.addLayout(self.horizontalLayout)

        self.textBrowser = QtGui.QTextEdit(Form)
        self.textBrowser.setObjectName("textBrowser")
        self.textBrowser.setReadOnly(True)
        self.verticalLayout.addWidget(self.textBrowser)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def createTastingDesc(self, type):
        textBrowser = QtGui.QTextEdit(Form)
        textBrowser.setObjectName(type+"text")
        textBrowser.setReadOnly(True)
        self.verticalLayout.addWidget(textBrowser)
        return textBrowser

    def setTastingText(self, t):
        #print 'displayTasting , setTastingText', t, t.dumpAsDict()
        text=[]

        for v,attDic in OrderedTastingAtt.iterattributes():

            tmpT = []
            for a,adesc in attDic: 
                tt = t[a]
                if tt:
                    tmpT.append('<b>%s :</b> %s'%(adesc,tt)  )
            if tmpT != []:
                a = v+'_desc'
                text.append('<h5>%s</h5> <div style="margin-left:50px">'%(OrderedTastingAtt[a]))
                #if t[a]: text.append( t[a] )
                text.append( '<br>'.join(tmpT))
                text.append('</div>')
        if t.comment:
            text.append('<h4>%s :</h4>    %s'%(OrderedTastingAtt.comment,t.comment)  )
            #text.append( t.comment)

        print '\n'.join(text) 
        self.textBrowser.setText( ''.join(text) )

                                   
        

    def retranslateUi(self, Form):
        #Form.setWindowTitle( tr("") )
        self.label_year.setText(tr("Year"))
        self.label_rate.setText(tr("Evaluation") )

